﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xna.Base;
using DC2010.Objects.Data;
using RolePlaying;
using Microsoft.Xna.Framework.Graphics;
using DC2010.Objects;
using Microsoft.Xna.Framework;

namespace DC2010
{
    public partial class Hud
    {

        public void DrawTreasure()
        {
            SpriteBatch spriteBatch = screenManager.SpriteBatch;
            CreatureData selectedMember = Root.I.GameSystem.SelectedMember;

            if (selectedMember != null)
            {
                //Creature c = Root.I.GameSystem.Party.Info.MembersBrowsable[selectedMember];

                //is something in left hand?
                ItemData id = selectedMember.Inventory.GetItemAtPosition(CarryLocations.LeftHand).GetItemDataFromCode();

                if (id != null)  //array is 0 based
                {
                    ItemInfo ii = Root.I.ItemSystem.GetInfo(id.InfoId);

                    if (ii.IsContainerItem)
                    {
                        spriteBatch.Draw(TM.GetTex("Interface/OpenChest"), RM.Get("Inventory_Treasure").GetVector(), Color.White);

                        //draw items
                        //int selectedMember = Root.I.GameSystem.SelectedMember;
                        //Creature c = Root.I.GameSystem.Party.Members[selectedMember];

                        int count = id.ContainerItems.Count;
                        for (int j = 0; j <= count - 1; j++)
                        {
                            string s = id.ContainerItems.GetItemAtPosition((CarryLocations)j);
                            ItemData itm = s.GetItemDataFromCode(); ;

                            if (itm != null)
                            {
                                TM.GetAnimation(itm.Gfx.Icon.Texture).Draw(spriteBatch, RM.Get("Inventory_Container_" + j).GetVector() + new Vector2(2, 2), 0f);
                            }
                        }
                    }
                }
            }
        }

    }
}
